package com.example.systems.service.impl;

import com.example.systems.entity.FileInfo;
import com.example.systems.mapper.FileInfoMapper;
import com.example.systems.service.FileInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 文件信息表 服务实现类
 * </p>
 *
 * @author honglujun
 * @since 2025-07-22 09:24:16
 */
@Service
public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> implements FileInfoService {

    @Autowired
    private FileInfoMapper fileInfoMapper;

    /**
     * 批量插入数据返回id
     *
     * @param fileInfos 文件信息
     * @return 主键id
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<Long> insertBatch(List<FileInfo> fileInfos) {
        fileInfoMapper.insertBatch(fileInfos);
        return fileInfos.stream().map(FileInfo::getId).collect(Collectors.toList());
    }

}
